home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPScrollArea.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  3.5 KB  |  127 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    10/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPScrollArea
  6.     
  7.     SUPERCLASS: CPPVisualObject
  8.     
  9.         This C++ class manages a scrollable area
  10.     
  11. ********************************************************************/
  12.  
  13.  
  14. #pragma once
  15.  
  16. #include <CPPVisualObject.h>
  17.  
  18. class CPPWindow;
  19.  
  20. class CPPScrollArea : public CPPVisualObject{
  21. public:
  22.  
  23.                     CPPScrollArea (CPPWindow *OurWindow,
  24.                                   Rect *ViewArea,
  25.                                   Rect *DestArea,
  26.                                   Boolean UseHScroll = TRUE,
  27.                                   Boolean UseVScroll = TRUE,
  28.                                   short hStep = 10, 
  29.                                   short vStep = 10);
  30.                     CPPScrollArea (CPPWindow *OurWindow,
  31.                                   Boolean UseHScroll = TRUE,
  32.                                   Boolean UseVScroll = TRUE,
  33.                                   short hStep = 10, 
  34.                                   short vStep = 10);
  35.                     ~CPPScrollArea (void);
  36.  
  37.     virtual    char     *ClassName (void);
  38.  
  39.     virtual    Boolean    DoCommand (short commandID);
  40.  
  41.     virtual    void    DoCut (void);
  42.     virtual    void    DoCopy (void);
  43.     virtual    void    DoPaste (void);
  44.     virtual    void    DoClear (void);
  45.     virtual    void    DoSelectAll (void);
  46.  
  47.     virtual    void    Activate (Boolean nowActive);
  48.     virtual    Boolean DoClick (EventRecord *theEvent);
  49.     virtual    void    DoIdle (void);
  50.             Rect    *GetAreaRect (void);
  51.     virtual    Rect    *GetBounds (void);
  52.     
  53.             void    Draw (void);
  54.     virtual    void    DrawContents (void);
  55.     virtual    void    MakeVisible (Boolean nowVisible);
  56.     virtual    void    TargetHilite (Boolean makeTarget);
  57.                         
  58.             
  59.             void    Area2Local (Point *thePoint);
  60.             void    Local2Area (Point *thePoint);
  61.             void    Area2Global (Point *thePoint);
  62.             void    Global2Area (Point *thePoint);
  63.  
  64.             void    SetHorizontalStep (short stepSize);
  65.             void    SetVerticalStep    (short stepSize);
  66.  
  67.             void     MoveScrollArea (void);
  68.          
  69.              long    AreaWidth (void);
  70.              long    AreaHeight (void);
  71.              long    ViewWidth (void);
  72.              long    ViewHeight (void);
  73.  
  74.              void    AutoScroll (void);
  75.  
  76. protected:
  77.     Rect            areaRect,    // the visible area in window coordinates
  78.                     destRect,    // the entire size of the area we control
  79.                     viewRect,    // the visible area in destRect coords
  80.                     selRect,    // the current selection in destRect coords
  81.                     bounds;        // temp variable used in GetBounds
  82.     ControlHandle    HScroll;
  83.     ControlHandle     VScroll;
  84.     Boolean            hasSelection;
  85.  
  86.     virtual    Boolean    DoScrollAreaClick (Point clickPt, short modifiers);
  87.     virtual    void    ResizeContent (short newWidth, short newHeight);
  88.     virtual    void    MoveContent (short newH, short newV);
  89.     
  90.             void    MakeSelection (Rect *newSelection);
  91.             void    RemoveSelection (void);
  92.     virtual    void    HiliteSelection (Boolean doHilight);
  93.     virtual    void    IdleSelection (void);
  94.     
  95. private:
  96.     short            hStep;
  97.     short            vStep;
  98.                     
  99.     static    CPPScrollArea    *gCurrentArea;
  100.     static    ControlHandle    gVScroll;
  101.     static    ControlHandle    gHScroll;
  102.                     
  103.     // static class methods
  104.     static pascal void Scroll_Right (ControlHandle theControl, 
  105.                                         short ctlPart);
  106.     static pascal void Scroll_Left (ControlHandle theControl, 
  107.                                         short ctlPart);
  108.     static pascal void Scroll_Up (ControlHandle theControl, 
  109.                                         short ctlPart);
  110.     static pascal void Scroll_Down (ControlHandle theControl, 
  111.                                         short ctlPart);
  112.  
  113.             void    VPageScroll (long part, long direction);
  114.             void    HPageScroll (long part, long direction);
  115.             void    AdjustScrollBar (void);
  116.             void     DoVScroller (Point clickPt, short part);
  117.             void    DoHScroller (Point clickPt, short part);
  118.  
  119.             void    MakeCPPScrollArea (CPPWindow *OurWindow, 
  120.                                        Rect *ViewArea, 
  121.                                        Rect *DestArea, 
  122.                                           Boolean UseHScroll, 
  123.                                           Boolean UseVScroll,
  124.                                           short hStep,
  125.                                           short vStep);
  126.  
  127. };